x86/emul: Don't use the ->cpuid() hook for feature checks
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 19 Jul 2018 15:57:41 +0000 (15:57 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 17 May 2019 15:37:46 +0000 (16:37 +0100)
commit346666c4bdf72ca1d908bbcdb9185981aac7e749
tree685ef7d1c13b4e18f7c6c91810d586127f8c1b76
parent4e069d60937b9cbffc3185f4e059f5dcc99e4cb0
x86/emul: Don't use the ->cpuid() hook for feature checks

For a release build of xen, this removes nearly 5k of code volume, and removes
a function pointer call from every instantiation.

  add/remove: 0/1 grow/shrink: 0/3 up/down: 0/-4822 (-4822)
  Function                                     old     new   delta
  adjust_bnd                                   260     244     -16
  x86_decode                                  8915    8890     -25
  vcpu_has.isra                                129       -    -129
  x86_emulate                               130040  125388   -4652
  Total: Before=3326565, After=3321743, chg -0.14%

Note that one corner case changes.  At the moment, it is possible for an
entity making direct DOMCTL_set_cpuid hypercalls to construct a policy with
max_leaf < 7, but feature bits set in leaf 7.  By default, libxc and libxl
don't do this, and the result is properly bounded by what the hardware is
capable of (so we won't start trying to use instructions which don't exist in
the CPU).

Previously, the cpuid() hook would end up hiding these features, but they may
still be set cpuid_policy, and therefore might start being accepted by
x86_emulate().

This corner case will be fixed by the in-progress DOMCTL_set_cpu_policy work,
and a guest would only encounter the corner case if it was constructed in a
non-standard manner, and if tried using instruction which it couldn't see
CPUID feature bits for.  As such, it isn't a corner case which we need to
worry about.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/x86_emulate/x86_emulate.c